#pragma once

#include "BaseInc.h"
#include "GdiplusEx.h"

class CPaint : public CPaintBase, public ITextEngine
{
public:
	CPaint(HDC hdc);
	~CPaint();
public:
	void SetClip(float_32 fX, float_32 fY, float_32 fWidth, float_32 fHeight);

	void SetTransform(const CMatrix3Float32 & matrix);
	void GetTransform(CMatrix3Float32 & matrix) const;
	void ResetTransform();

	void SetImageColorMatrix(const CMatrix5Float32 & matrix);
	void GetImageColorMatrix(CMatrix5Float32 & matrix) const;
	void ResetImageColorMatrix();

	void SetTextRendLevel(TextRenderlevel renderLevel);

	void SetTextFormat(const FontFormat & format);
	void GetTextFormat(FontFormat & format) const;

	TextRenderlevel GetTextRendLevel() const;

	void Clear(uint_32 uiColor);

	void SetPixel(float_32 fX, float_32 fY, uint_32 uiColor);
	uint_32 GetPixel(float_32 fX, float_32 fY);

	void DrawLine(float_32 fX1, float_32 fY1, float_32 fX2, float_32 fY2, IPen * pPen);

	void DrawRect(float_32 fX, float_32 fY, float_32 fWidth, float_32 fHeight, IPen * pPen);
	void FillRect(float_32 fX, float_32 fY, float_32 fWidth, float_32 fHeight, IBrush * pBrush);

	void DrawBezier3(float_32 fX1, float_32 fY1, float_32 fX2, float_32 fY2, float_32 fX3, float_32 fY3, IPen * pPen);
	void DrawBezier4(float_32 fX1, float_32 fY1, float_32 fX2, float_32 fY2, 
		float_32 fX3, float_32 fY3, float_32 fX4, float_32 fY4, IPen * pPen);

	void DrawArc(float_32 fX, float_32 fY, float_32 fWidth, float_32 fHeight, float_32 fStartAngle, float_32 fAngle, IPen * pPen);

	void DrawString(const char_16 * szText, int_32 iLen, float_32 fX, float_32 fY, IBrush * pBrush);
	void DrawString(const char_16 * szText, int_32 iLen, 
		float_32 fX, float_32 fY, float_32 fWidth, float_32 fHeight, IBrush * pBrush);

	void MeasureString(const char_16 * szText, int_32 iLen, const FontFormat & format, CSizeInt32 & siMeasure);

	void DrawImage(IImage * pImage, 
		float_32 fDstX, float_32 fDstY, float_32 fDstWidth, float_32 fDstHeight,
		float_32 fSrcX, float_32 fSrcY, float_32 fSrcWidth, float_32 fSrcHeight);

	void DrawPath(const IPath * pPath, IPen * pPen);

private:
	GpsImage * GetImage(IImage * pImage);
private:
	GpsGraphics m_graphics;

	CMatrix5Float32 m_matrColorMatrix;
	bool m_bColorMatrix;

	FontFormat m_textFormat;
};
